/**
 * Copyright (C), 2020-2021 by colley.ma
 * File Name: ExtensionAutoConfiguration.java
 * Encoding: UTF-8
 * Date: 2021年3月31日 上午11:25:08
 * History:
*/
package com.swak.frame.spring.configuration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.swak.frame.extension.ExtensionFinder;
import com.swak.frame.extension.adapter.FutureClockTime;
import com.swak.frame.extension.adapter.RiskWhiteListAdapter;
import com.swak.frame.extension.adapter.WhiteListAdapter;
import com.swak.frame.extension.executor.DefaultExtensionExecutor;
import com.swak.frame.extension.executor.ExtensionExecutor;
import com.swak.frame.extension.repository.AnnotationExtensionFinder;
import com.swak.frame.extension.repository.DefaultExtensionRepository;
import com.swak.frame.extension.repository.ExtensionRepository;

@Configuration(proxyBeanMethods = false)
public class SwakExtensionAutoConfiguration {

	@Bean
	@ConditionalOnMissingBean(ExtensionRepository.class)
	public ExtensionRepository extensionRepository() {
		return new DefaultExtensionRepository();
	}

	@Bean
	@ConditionalOnMissingBean(ExtensionFinder.class)
	public ExtensionFinder extensionFinder() {
		return new AnnotationExtensionFinder();
	}

	@Bean
	@ConditionalOnMissingBean(ExtensionExecutor.class)
	public ExtensionExecutor extensionExecutor() {
		return new DefaultExtensionExecutor();
	}

	@Bean
	@ConditionalOnMissingBean(WhiteListAdapter.class)
	public WhiteListAdapter whiteListAdapter(ExtensionExecutor extensionExecutor) {
		return new WhiteListAdapter(extensionExecutor);
	}

	@Bean
	@ConditionalOnMissingBean(FutureClockTime.class)
	public FutureClockTime futureTimeClock(ExtensionExecutor extensionExecutor) {
		return new FutureClockTime(extensionExecutor);
	}

	@Bean
	@ConditionalOnMissingBean(RiskWhiteListAdapter.class)
	public RiskWhiteListAdapter riskWhiteListAdapter(ExtensionExecutor extensionExecutor) {
		return new RiskWhiteListAdapter(extensionExecutor);
	}
}
